<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #tableButtons>
        <a-button @click="crudRef.addAction()">大货拣货</a-button>
        <a-button >快捷查单</a-button>
        <a-button >Execl批量拣货</a-button>
      </template>
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import picking from '@/api/warehouse/picking'
import dicthelper from "@/utils/dicthelp.js";

const crudRef = ref()

const options = reactive({
  id: 'picking',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  tabs:{
    dataIndex:"status"
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: picking.getList,
  add: {
    show: true,
    api: picking.save,
    auth: ['warehouse:picking:save'],
    
  },
  edit: {
    show: true,
    api: picking.update,
    auth: ['warehouse:picking:update']
  },
  delete: {
    show: true,
    api: picking.deletes,
    auth: ['warehouse:picking:delete']
  },
  import: {
    show: true,
    url: 'warehouse/picking/import',
    templateUrl: 'warehouse/picking/downloadTemplate',
    auth: ['warehouse:picking:import']
  }
})

const columns = reactive([
  {
    title: "编号",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "用户",
    dataIndex: "user_id",
    formType: "select",
      dict:dicthelper.customer,
    search: true,

    commonRules: {
      required: true,
      message: "请输入用户"
    }
  },
  {
    title: "类型",
    dataIndex: "type",
    formType: "select",
    dict: {
       data:[
          {label:'手动拣货',value:'1'},
       ],
       translation: true,
      },
    search: true,
    commonRules: {
      required: true,
      message: "请输入类型"
    }
  },
  {
    title: "货站",
    dataIndex: "depot_id",
    formType: "select",
      dict:{
        url: 'warehouse/depot/list',
        props: {label: 'name', value: 'id'},
        translation: true,
        params:{
          select: 'id,name',
        }
      },

    commonRules: {
      required: true,
      message: "请输入货站"
    }
  },
  {
    title: "重量",
    dataIndex: "weight",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入重量"
    }
  },
  {
    title: "数量",
    dataIndex: "count",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入体积"
    }
  },
  {
    title: "体积",
    dataIndex: "volume",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入体积"
    }
  },
  {
    title: "状态",
    dataIndex: "status",
    formType: "select",
    dict:{
      data:[
          {label:'拣货中',value:'0'},
          {label:'已完成',value:'1'},
      ],
      translation: true,
    },
    search: true,
    commonRules: {
      required: true,
      message: "请输入状态"
    }
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'warehouse:picking' } </script>